package com.hx.jvm.jvm.oom;

import java.util.ArrayList;
import java.util.List;

/**
 * 测试堆内存溢出
 *
 * @author jxrjc
 * <p>
 * JVM参数： -Xms20M -Xmx20M -XX:+HeapDumpOnOutOfMemoryError
 * <p>
 * 错误信息：
 * java.lang.OutOfMemoryError: Java heap space
 * Dumping heap to java_pid14936.hprof ...
 * Heap dump file created [27985095 bytes in 0.128 secs]
 */
public class HeapOOM {

    public static void main(String[] args) {
        List<OOMObject> list = new ArrayList<>();
        while (true) {
            list.add(new OOMObject());
        }
    }

    static class OOMObject {

    }

}
